#ifndef __MYSTRING_H_
#define __MYSTRING_H_
#include <iostream>
class mystringArray;//前置声明
class mystring{
public:
    mystring();
    mystring(const char *str);
    mystring(const mystring& s);
    mystring& operator=(const mystring &str);
    ~mystring();
    mystring& operator+=(const mystring &string);
    mystring& operator+=(const char &c);
    mystring operator+(const mystring &string);
    mystring& operator-=(const mystring &string);
    mystring operator-(const mystring &string);
    char& operator[](int index);
    bool operator==(const mystring &string);
    bool operator!=(const mystring &string);
    //bool operator&&(const mystring &string);
    //类型转换运算符重载
    operator int();
    operator double();

    //字符串切割
    mystringArray split(const mystring& delim);

    friend std::ostream& operator<<(std::ostream &os,const mystring& str);
    friend std::istream& operator>>(std::istream &is, mystring& str);
private:
    char *s;
    int size;
    int capacity;
    void reSize(int capacity);
};
std::ostream& operator<<(std::ostream &os,const mystring& str);
std::istream& operator>>(std::istream &is, mystring& str);

class mystringArray{
public:
    mystringArray();
    mystringArray(const mystringArray& a);
    mystringArray& operator=(const mystringArray& a);
    ~mystringArray();
    //+ -= - == [] >>
    mystring& operator[](int index);
    bool operator==(const mystringArray &a);
    mystringArray& operator+=(const mystring& str);
    mystringArray operator+(const mystring& str);
    mystringArray& operator-=(const mystring& str);
    mystringArray operator-(const mystring& str);
    friend std::ostream& operator<<(std::ostream &os,const mystringArray& a);
    friend std::istream& operator>>(std::istream &is, mystringArray& a);

private:
    mystring *array;
    int size;
    int capacity;

};
std::ostream& operator<<(std::ostream &os,const mystringArray& a);
std::istream& operator>>(std::istream &is, mystringArray& a);


#endif